unit TestForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, DBClient, ADODB, XPMan, Grids, DBGrids;

type
  TfmTest = class(TForm)
    btnTestGetOraclePath: TButton;
    btnTestGetTnsNames: TButton;
    btnViewDataSetForm: TButton;
    dsViewDataSetForm: TClientDataSet;
    tblTest: TADOTable;
    XPManifest1: TXPManifest;
    btnGetTableNames: TButton;
    conn: TADOConnection;
    DBGrid1: TDBGrid;
    Button1: TButton;
    DataSource1: TDataSource;
    ADODataSet1: TADODataSet;
    btnGetTableColumns: TButton;
    procedure btnGetTableColumnsClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure btnGetTableNamesClick(Sender: TObject);
    procedure btnViewDataSetFormClick(Sender: TObject);
    procedure btnTestGetTnsNamesClick(Sender: TObject);
    procedure btnTestGetOraclePathClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmTest: TfmTest;

implementation

uses FiagOracle, FiagSystem, FiagWinSys, FiagADO, AdoConEd;

{$R *.dfm}

procedure TfmTest.btnTestGetOraclePathClick(Sender: TObject);
begin
  ShowMessage('Oracle Install Path : ' + GetOracleInstallPath);
end;

procedure TfmTest.btnTestGetTnsNamesClick(Sender: TObject);
begin
  ShowMessage('TNS names : '#13 + GetTnsNames.Text);
end;

procedure TfmTest.btnViewDataSetFormClick(Sender: TObject);
begin
  dsViewDataSetForm.LoadFromFile(GetBorlandSharedPath +
    'Data\animals.xml');
  ViewDataSetForm(dsViewDataSetForm);
  //  tblTest.Active:=True;
  //  ViewDataSetForm(tblTest);
end;

procedure TfmTest.btnGetTableNamesClick(Sender: TObject);
var
  tmpStr: string;
  tmp: TStrings;
begin
  if AdoConEd.EditConnectionString(conn) then
  begin
    tmpStr := conn.ConnectionString;
    tmp := GetTableNames(tmpStr, ExtractUserId(tmpStr));
    tmpStr := tmp.Text;
    FreeAndNil(tmp);
    MessageDlg(tmpStr, mtInformation, [mbOK], 0);
  end;
end;

procedure TfmTest.Button1Click(Sender: TObject);
var
  tmpStr: string;
  tmp: TStrings;
begin
  if AdoConEd.EditConnectionString(conn) then
  begin
    tmpStr := conn.ConnectionString;
    tmp := GetPrimaryKeys(tmpStr, 'T_MENULOG2');
    if tmp.Count>0 then
      tmpStr := tmp.Text
    else
      tmpStr := 'No Primary Key!';
    FreeAndNil(tmp);
    MessageDlg(tmpStr, mtInformation, [mbOK], 0);
  end;
end;

procedure TfmTest.btnGetTableColumnsClick(Sender: TObject);
var
  tmpStr: string;
  tmp: TStrings;
begin
  if AdoConEd.EditConnectionString(conn) then
  begin
    tmpStr := conn.ConnectionString;
    tmp := GetTableColumns(tmpStr, ExtractUserId(tmpStr), 'T_DEMO');
    tmpStr := tmp.Text;
//    tmp.Delimiter:=',';
//    tmpStr := tmp.DelimitedText;
    FreeAndNil(tmp);
    MessageDlg(tmpStr, mtInformation, [mbOK], 0);
  end;
end;

end.

